package a10_动态规划;

import java.util.Arrays;

/**
 * <p>
 * a41_最长递增子序列复习1
 * </p>
 *
 * @author flyduck
 * @since 2025/2/26
 */
public class a41_最长递增子序列复习1 {
    //dp[i]:包含nums[i]的最长递增序列的长度

    //dp[i]=Math.max(dp[0]+1,dp[1]+1,...,dp[i-1]+1)

    //dp[0]=1
    public int lengthOfLIS(int[] nums) {
        int result = 1;

        int[] dp = new int[nums.length];
        Arrays.fill(dp, 1);

        for (int i = 1; i < nums.length; i++) {
            for (int j = 0; j < i; j++) {
                if(nums[i] > nums[j]){
                    dp[i] = Math.max(dp[i],dp[j]+1);
                }
            }
            result = Math.max(dp[i],result);
        }
        return result;

    }
}
